package com.h3c.web.common.utils;

import java.util.List;

import org.springframework.beans.BeanUtils;

import com.google.common.collect.Lists;

public class ListUtil {
	public static boolean isEmpty(List<?> list) {
		if (list == null || list.isEmpty()) {
			return true;
		}
		return false;
	}
	public static boolean isNotEmpty(List<?> list) {
		if (list != null && list.size() > 0) {
			return true;
		}
		return false;
	}
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public static List copyList(List<? extends Object> sourceList, Class targetClazz) throws Exception {
		if (sourceList == null || sourceList.isEmpty()) {
			return null;
		}
		List targetList = Lists.newArrayList();
		for (Object source : sourceList) {
			Object target = targetClazz.newInstance();
			BeanUtils.copyProperties(source, target);
			targetList.add(target);
		}
		return targetList;
	}
}
